{include file="public/_meta" /}
<body>
<style>
    .required_b{
        color: red;
    }
</style>
<div class="wrapper">

    {include file="public/_header" /}

    <!-- Sidebar -->
    {include file="public/_menu" /}
    <!-- End Sidebar -->

    <div class="main-panel">

        <div class="content">
            <div class="page-inner">

                <!-- 面包屑 -->
                {include file="public/_page_header" /}

                <div class="row">
                    <div class="col-md-12">
                        <div class="card">
                            <div class="card-header">
                                <div class="d-flex align-items-center">
                                    <h4 class="card-title">投放商户统计</h4>
<!--                                    <div class="layui-btn-container" style="margin-left: 65%">-->
<!--                                        <button type="button" class="layui-btn layui-btn-normal" id="test8">选择文件</button>-->
<!--                                        <button type="button" class="layui-btn" id="test9">导入</button>-->
<!--                                    </div>-->
<!--                                    <button class="btn btn-primary btn-round ml-auto" data-toggle="modal" data-target="#addRowModal" onClick="add_item(0)">-->
<!--                                        <i class="fa fa-plus"></i>-->
<!--                                        添加-->
<!--                                    </button>-->

                                </div>

                                <form class="row">




                                    <div class="col-md-6 col-lg-2">
                                        <div class="form-group">
                                            <input type="text" class="form-control" name="mer_name" value="{$mer_name}" placeholder="商户名称">
                                        </div>
                                    </div>


                                    <div class="col-md-6 col-lg-2">
                                        <div class="form-group">
                                            <input type="text" class="form-control" name="cityname" value="{$cityname}" placeholder="请输入城市">
                                        </div>
                                    </div>


                                    <div class="col-md-6 col-lg-2">
                                        <div class="form-group">

                                            <select class="form-control input-full" name="pro_id" id="pro_id">
                                                <option value="">全部产品</option>
                                                {volist name="products" id="vo"}
                                                <option value="{$key}">{$vo}</option>
                                                {/volist}
                                            </select>
                                        </div>
                                    </div>


                                    <div class="col-md-6 col-lg-2">
                                        <div class="form-group">
                                            <input type="text" class="form-control" name="times" id="times" value="{$showTime}" placeholder="时间" autocomplete="off">
                                        </div>
                                    </div>


                                    <div class="col-md-6 col-lg-2">
                                        <div class="form-group">
                                            <button type="submit" class="btn btn-primary">查询</button>
                                            <button type="button" class="btn btn-primary" onclick="dataexport()">导出</button>
                                            <a href="{:url('Operate/accountClueTotal')}" class="btn btn-info" style="color: white;position: absolute;left: 200px;">重置</a>
                                        </div>
                                    </div>

                                </form>

                            </div>

                            <div class="layui-card-body">

                                <blockquote class="layui-elem-quote layui-quote-nm">


                                    <div class="table-responsive">
                                        <table id="add-row2" class="display table table-striped table-hover" >
                                            <thead>
                                            <tr>
<!--                                                <th>本页统计</th>-->
                                                <th>分发执行量</th>
                                                <th>分发成功量</th>
                                                <th>分发损耗率</th>
<!--                                                <th>分发执行总成本</th>-->
<!--                                                <th>分发成功总成本</th>-->
<!--                                                <th>损耗金额</th>-->
<!--                                                <th>成本单价</th>-->
                                                <th>总结算额</th>
                                                <th>结算单价</th>
                                                <th>撞库数</th>
                                                <th>撞库率</th>
<!--                                                <th>毛利</th>-->
                                            </tr>
                                            </thead>

                                            <tbody>

                                            <tr>
<!--                                                <td>第{$infos->currentPage()}页</td>-->
                                                <td>{$allExecuteNum}</td>
                                                <td>{$allFenfaNum}</td>
                                                <td>{$shunHaoRate}%</td>
<!--                                                <td>{$fenfaAllCostMoney}</td>-->
<!--                                                <td>{$fenfaSuccessMoney}</td>-->
<!--                                                <td>{$shunhaoMoney}</td>-->
<!--                                                <td>{$costPrice}</td>-->
                                                <td>{$allJieSuan}</td>
                                                <td>{$jiesuanPirce}</td>
                                                <td>{$zhuangkuNum}</td>
                                                <td>{$zhuangkuRate}%</td>
<!--                                                <td>{$lirun}</td>-->

                                            </tr>

                                            </tbody>
                                        </table>


                                    </div>


                                </blockquote>
                            </div>


                            <div class="card-body">
                                <!-- Modal -->


                                <div class="table-responsive">
                                    <table id="add-row" class="display table table-striped table-hover" >
                                        <thead>
                                        <tr>

                                            <th>商户信息</th>

                                            <th>城市</th>

                                            <th>产品</th>

                                            <th>分发执行量</th>
                                            <th>分发成功量</th>
                                            <th>分发损耗率</th>
<!--                                            <th>分发执行总成本</th>-->
<!--                                            <th>分发成功总成本</th>-->
<!--                                            <th>损耗金额</th>-->
<!--                                            <th>成本单价</th>-->
                                            <th>总结算额</th>
                                            <th>结算单价</th>
                                            <th>撞库数</th>
                                            <th>撞库率</th>
<!--                                            <th>毛利</th>-->
                                            <th>账户币余额</th>

                                        </tr>
                                        </thead>

                                        <tbody>

                                        {volist name="infos" id="vo"}
                                        <tr>


                                            <td>
                                                账号：{$vo.username}<br>
                                                手机：{$vo.mer_phone}<br>
                                                商户名：{$vo.mer_name}
                                            </td>

                                            <td>{$vo.city}</td>
                                            <td>{$vo.pro_name}</td>

                                            <td>{$vo.execute_num}</td>
                                            <td>{$vo.num}</td>
                                            <td>{$vo.fenfa_shunhao_rate}%</td>
<!--                                            <td>{$vo.execute_money}</td>-->
<!--                                            <td>{$vo.cost_price}</td>-->
<!--                                            <td>{$vo.shunhao_money}</td>-->
<!--                                            <td>{$vo.chengben_avg}</td>-->
                                            <td>{$vo.price}</td>
                                            <td>{$vo.jiesuan_avg}</td>
                                            <td>{$vo.re_phone}</td>
                                            <td>{$vo.re_phone_rate}%</td>
<!--                                            <td>{$vo.lirun}</td>-->
                                            <td>{$vo.balance}</td>

                                        </tr>
                                        {/volist}

                                        </tbody>
                                    </table>

                                    <!-- 分页 (调取通用方法)-->
                                     <div class="layui-box layui-laypage layui-laypage-molv">{:pagination($infos)}</div>

                                </div>
                            </div>
                        </div>
                    </div>
                </div>


            </div>
        </div>

        {include file="public/_footer" /}


    </div>



</div>

{include file="public/_js" /}

</body>

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript">
    var SCOPE = {
        'status_url':"{:url('clue/status')}",
        'delete_url':"{:url('clue/delete')}",
        'item_url':"{:url('clue/edit')}",
        'item_url2':"{:url('clue/edit2')}",
        'add_url':"{:url('clue/save')}",
        'clue_url':"{:url('clue/clue_url')}",
        'city_url':"{:url('clue/getRegion')}",
        'push_rule':"{:url('clue/getMerchantPush')}",
        'push_url':"{:url('clue/findPush')}",
        'get_account':"{:url('stat/getAccount')}",
        'saveclue':"{:url('stat/saveClueCost')}",
        'editclue':"{:url('stat/editClueCost')}",
        'del_clue':"{:url('stat/delClueCost')}",
        'improtexcel':"{:url('stat/importClueCost')}",
    };




    $(function(){
        var commitStatus = false;
        /*表单验证*/
        $("#form-modal").validate({
            rules:{
                clue_name:{
                    required:true,
                    maxlength:30
                },
                phone:{
                    required:true,
                    number:true,
                    minlength:11,
                    maxlength:11
                },
                age:{
                    number:true
                },
                email:{
                    email:true,
                    maxlength:100
                },
                wx_id:{
                    maxlength:30
                },
                qq:{
                    maxlength:30
                },
                remark:{
                    maxlength:300
                }

            },
            onkeyup:false,
            focusCleanup:true,
            success:"valid",
            submitHandler:function(form){
                var url = SCOPE.saveclue;
                if(commitStatus==true){
                    return false;
                }
                var province = $("#province").val();
                var city = $("#city").val();
                if(province != 0 && city == 0){
                    layer.msg('请选择市/县',{icon:2,time:2000});
                    return false;
                }
                /*表单提交*/
                $(form).ajaxSubmit({
                    type: 'post',
                    url: url,
                    success: function(data){
                        if(data.code == 1001){
                            commitStatus = true;
                            layer.msg(data.msg, {
                                icon: 1,
                                time: 2000
                            }, function(){
                                parent.location.reload();
                            });
                        }else{
                            layer.msg(data.msg,{icon:2,time:2000});
                        }
                    },
                    error: function(XmlHttpRequest, textStatus, errorThrown){
                        layer.msg(errorThrown,{icon:2,time:2000});
                    }
                });

            }
        });

    });

    $(function(){
        var commitStatus = false;
        /*表单验证*/
        $("#form-modal2").validate({

            onkeyup:false,
            focusCleanup:true,
            success:"valid",
            submitHandler:function(form){
                var url = SCOPE.push_url;
                if(commitStatus==true){
                    return false;
                }

                /*表单提交*/
                $(form).ajaxSubmit({
                    type: 'post',
                    url: url,
                    success: function(data){
                        if(data.code == 1001){
                            commitStatus = true;
                            layer.msg(data.msg, {
                                icon: 1,
                                time: 2000
                            }, function(){
                                parent.location.reload();
                            });
                        }else{
                            layer.msg(data.msg,{icon:2,time:2000});
                        }
                    },
                    error: function(XmlHttpRequest, textStatus, errorThrown){
                        layer.msg(errorThrown,{icon:2,time:2000});
                    }
                });

            }
        });

    });





    laydate.render({
        elem: '#times'
        ,type: 'date'
        ,range: true
    });

    //自定义格式
    laydate.render({
        elem: '#dtime'
        ,format: 'yyyy-MM-dd'
    });

    // $('#pro_id').find('option[value="{$pro_id}"]').attr('selected',true);
    $('#pro_id').val('{$pro_id}');



    function dataexport(){
        var mer_name=$("[name='mer_name']").val();
        var cityname=$("[name='cityname']").val();
        var pro_id=$("[name='pro_id']").val();
        var times=$("[name='times']").val();
        location.href="{:url('Operate/accountClueTotalMerchantExport')}"+'?cityname='+cityname+'&pro_id='+pro_id+'&mer_name='+mer_name+'&times='+times;
    }

</script>
<script src="__STATIC__/layui/layui.js"></script>
<script>
    layui.use(['upload', 'element', 'layer'], function() {
        var $ = layui.jquery
            , upload = layui.upload
            , element = layui.element
            , layer = layui.layer;

        //选完文件后不自动上传
        upload.render({
            elem: '#test8'
            ,url: "{:url('stat/importClueCost')}" //此处配置你自己的上传接口即可
            ,auto: false
            //,multiple: true
            ,accept:'file'
            ,bindAction: '#test9'
            ,done: function(res){
                if(res.code == 1001){
                    layer.msg(res.msg,{icon: 1,time:1000},function(){
                        window.location.reload();
                    });
                }else{
                    layer.msg(res.msg,{icon: 2,time:3000});
                }
            }
        });
    });
</script>
</html>




























